If you're viewing this notebook on github and don't see the pie chart at the end, view it on the jupyter nbviewer instead.
This is a trivial example demonstrating how to connect to a ga4gh server, select annotations from one annotation set, and generate a pie chart from Sequence Ontology terms associated with all variants. When applied to gene coordinates and a specific transcript, a similar query would correspond to the observed mutation spectrum.
The original query was lifted from David Steinberg.
In [1]:
import collections
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
init_notebook_mode()
import plotly.graph_objs as go
import ga4gh.client as client
args=dict(
variantAnnotationSetId = "YnJjYTE6T1I0Rjp2YXJpYW50YW5ub3RhdGlvbnM",
referenceName = "1",
start = 0,
end = 300000000
)
In [2]:
gc = client.HttpClient("http://localhost:8000")
In [3]:
annotation_set = gc.getVariantAnnotationSet(args["variantAnnotationSetId"])
In [4]:
c = collections.Counter(
ef.term
for va in gc.searchVariantAnnotations(**args)
for te in va.transcriptEffects
for ef in te.effects)
In [5]:
labels, values = zip(*c.most_common())
fig = {
'data': [{'labels': labels, 'values': values, 'type': 'pie'}],
'layout': {'title': """Transcript effects for {a[referenceName]}:{a[start]}-{a[end]}"""
"""<br>variant annotation set {a[variantAnnotationSetId]}""".format(a=args)}
}
iplot(fig)
In [ ]: